export default {
	namespaced:true,
	state:()=>({
		address:JSON.parse(uni.getStorageSync('address')||'{}'),
		token:uni.getStorageSync('token') || '',
		userinfo:JSON.parse(uni.getStorageSync('userinfo')||'{}'),
		redirectInfo:null //重定向的对象
	}),
	mutations:{
		upaddress(state,address){
			state.address = address
			this.commit('m_user/saveAddress')
		},
		// 持久化存储address
		saveAddress(state){
			uni.setStorageSync('address',JSON.stringify(state.address))
		},
		// 修改userinfo的数据
		updateuserinfo(state,userinfo){
			state.userinfo = userinfo
			this.commit('m_user/saveuserinfo')
		},
		// 持久化存储userinfo
		saveuserinfo(state){
			uni.setStorageSync('userinfo',JSON.stringify(state.userinfo))
		},
		updataToken(state,token){
			state.token = token
			this.commit('m_user/savaTokenTostoage')
		},
		savaTokenTostoage(state){
			uni.setStorageSync('token',state.token)
		},
		updaredirectInfo(state,info){
			state.redirectInfo = info
		}
	},
	getters:{
		addstr(state){
			if(!state.address.telNumber){
				return  ''
			}
			else{
			return	state.address.provinceName+state.address.cityName+state.address.countyName + state.address.detailInfo
			}
		}
	}
}